import turtle
import math

def draw_square(pen, x, y, length):
    pen.penup()
    pen.goto(x - length / 2, y - length / 2)
    pen.setheading(0)  # 将绘制方向初始化为向右
    pen.pendown()
    for _ in range(4):
        pen.forward(length)
        pen.left(90)

def draw_board(pen, j):
    pen.color('black')
    pen.pensize(1)

    length_j = 50  # 棋盘的边长固定为50

    center_x = j * (length_j + 50)  # 棋盘的x坐标，每个棋盘的间隔为50

    center_y = 0  # 棋盘的y坐标，保持为0

    # 绘制开始的三个方块
    for i in range(3):
        length_i = 50 * (i + 1)
        draw_square(pen, center_x, center_y, length_i)

    # 连接正方形的四边
    pen.penup()
    pen.goto(center_x - length_j / 2, center_y)
    pen.pendown()
    pen.setheading(180)
    pen.forward(length_j)

    pen.penup()
    pen.goto(center_x + length_j / 2, center_y)
    pen.pendown()
    pen.setheading(0)
    pen.forward(length_j)

    pen.penup()
    pen.goto(center_x, center_y - length_j / 2)
    pen.pendown()
    pen.setheading(270)
    pen.forward(length_j)

    pen.penup()
    pen.goto(center_x, center_y + length_j / 2)
    pen.pendown()
    pen.setheading(90)
    pen.forward(length_j)

    # 绘制红色的方块
    pen.color('red')
    pen.pensize(3)
    draw_square(pen, center_x, center_y, length_j)

canvas = turtle.Screen()
pen = turtle.Turtle()

draw_board(pen, 0)
draw_board(pen, 1)

canvas.exitonclick()
